import random

from fastapi import APIRouter

from service.attendance import PunchClockRequest, punch_clock

router = APIRouter()

lgts = [117.490584, 117.490583, 117.490674, 117.490680, 117.490763, 117.490762]
lats = [38.974014, 38.974013, 38.973842, 38.973768, 38.973767, 38.973766, 38.973765]


@router.get("/comeWork", summary="上班")
def come_work():
	return work(1)


@router.get("/goOffWork", summary="下班")
def go_off_work():
	return work(3)


def work(card_type: int):
	lgt = random.choice(lgts)
	lat = random.choice(lats)
	# date_str = date.strftime(date.today(), "%Y%m%d")
	# id_str = str(uuid.uuid1()).replace("-", "")
	# face_url = f"https://rock-check.obs.cn-southwest-2.myhuaweicloud.com:443/{date_str}_{id_str}.png"
	face_url = ""
	request = PunchClockRequest(
		lgt=lgt,
		lat=lat,
		cardType=card_type,
		cardPlace="天津市津南区邓岑子路44号-天津荣程联合钢铁集团有限公司(西1门)附近",
		userFaceUrl=face_url,
	)
	return punch_clock(request=request)
